package com.wsd.smartcarwasher.util;

import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;

public class CaculateDistance {

    public static double getDistanceMeter(String slng,String slat,String tlng,String tlat)
    {
        GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(slat), Double.valueOf(slng));
        GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(slat), Double.valueOf(tlng));

        //创建GeodeticCalculator，调用计算方法，传入坐标系、经纬度用于计算距离
        GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.WGS84, source, target);

        return geoCurve.getEllipsoidalDistance()/1000;
    }
}
